package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsFeedbackMapper;
import com.qf.pojo.DtsFeedback;
import com.qf.service.DtsFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author 邢式瑞
 * @version 1.0
 * @project E-commercebackGroundManagementSystem
 * @date 2022/9/22 22:35
 */
@Service
public class DtsFeedbackServiceImpl implements DtsFeedbackService {
    @Autowired
    private DtsFeedbackMapper feedbackMapper;
    @Override
    public Page<DtsFeedback> selectPage(Integer page, Integer limit, String sort, String order, String username, Integer id) {
        Page<DtsFeedback> dtsFeedbackPage = new Page<>(page, limit);
        QueryWrapper<DtsFeedback> dtsFeedbackQueryWrapper = new QueryWrapper<>();
        dtsFeedbackQueryWrapper.orderBy(!StringUtils.isEmpty(sort),"asc".equalsIgnoreCase(order),sort).like(!StringUtils.isEmpty(username),"username",username).eq(id!=null,"id",id);
        return feedbackMapper.selectPage(dtsFeedbackPage,dtsFeedbackQueryWrapper);
    }
}
